package com.basemanage.controller.api;

import javax.xml.ws.Action;

import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.DisabledAccountException;
import org.apache.shiro.authc.ExcessiveAttemptsException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;

import com.basemanage.controller.IndexController;
import com.basemanage.core.auth.interceptor.SysLogInterceptor;
import com.basemanage.core.controller.JCBaseController;
import com.basemanage.core.shiro.plugin.ClearShiro;
import com.basemanage.core.shiro.plugin.ShiroInterceptor;
import com.basemanage.core.view.InvokeResult;
import com.jfinal.aop.Clear;
import com.jfinal.core.ActionKey;
import com.jfinal.core.Controller;
/*
 *  api
 */
import com.jfinal.kit.StrKit;


public class ApiController extends JCBaseController {
	
	/*
	 * 登录接口
	 */
	/**
	 * 用户登录
	 */
	@ActionKey( value ="/api/login")
	public void dologin() {

		String username = this.getPara("username");
		String password = this.getPara("password");
	  
		Subject subject = this.getSubject();  
		
		if(!subject.isAuthenticated()){

			UsernamePasswordToken token = new UsernamePasswordToken(username, password);
			subject.login(token);
			if(subject.isAuthenticated()){
				renderJson("登录成功");
	
			}
		}else{
			renderJson("登录成功");

		}

	}
	/*
	 * 首页
	 */
	

	@ActionKey( value = "api/test")
	public void index(){

		

		
		renderJson("test");
	}
	
	/*
	 * 测试
	 */
	

}
